package mess;

import java.time.temporal.Temporal;

public class LeeCode_11 {
    public static void main(String[] args) {
        int[] nums = {1,8,6,2,5,4,8,3,7};
        System.out.println(maxArea(nums));
    }
    private static int maxArea(int[] height) {
        int len = height.length;
        int start = 0;
        int end = len - 1;
        int max = 0;
        while (start < end){
            int w = end - start;
            int h;
            if (height[start] >= height[end]) {
                h = Math.min(height[start], height[end]);
                max = Math.max(max, w * h);
                end--;
            } else {
                h = Math.min(height[start], height[end]);
                max = Math.max(max, w * h);
                start++;
            }
        }
        return max;
    }
}
